import request from '@/utils/request';

const productCarUrl = '/product/v1/product/productCar';

/**
 * 购物车商品列表加减商品数量
 * @param data
 * data.id 购物车主键id
 * number 商品数量
 * @returns {Promise<*>}
 */
export async function productCarUpdateProductNum(data) {
  return request({
    url: `${productCarUrl}/updateProductNum`,
    method: 'POST',
    data: data,
  });
}

/**
 * 删除购物车商品
 * @param data
 * data.id 购物车主键id
 * @returns {Promise<*>}
 */
export async function productCarDeleteProductId(data) {
  const { id } = data;
  return request({
    url: `${productCarUrl}/deleteProduct/${id}`,
    method: 'GET',
  });
}

// 批量删除购物车商品列表
export async function batchDeleteProductsServer(data) {
  return request({
    url: `${productCarUrl}/batchDeleteProductCars`,
    method: 'DELETE',
    data,
  });
}
